package com.itheima.array;
import java.util.Random;
import java.util.Scanner;

public class arrayDemo3 {
    public static void main(String[] args) {
        // 生成随机数
        extracted();
        //arrTest();
        getMax();

    }

    private static void extracted() {
        Random r=new Random();
        int[] randomNums=new int[10];
        for (int i = 0; i < randomNums.length; i++) {
            randomNums[i]=r.nextInt(100)+1;
        }
    }

    public static void  arrTest(){
        int[] arr=new int[3];
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
    // 动态初始化，键盘录入5个学生成绩，求最大值
    public static void getMax(){
        Scanner sc=new Scanner(System.in);
        int[] arr=new int[5];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"位学生成绩");
            arr[i]=sc.nextInt();
        }
        int max=arr[0];
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]>max){
                max=arr[i];
            }
        }
        System.out.println("成绩最大值为"+max);
    }
}
